package com.leoandroid.tool.toolsbox.utils;

import java.util.Calendar;
import java.util.Date;

public class DateUtils {
    public static String getWeek(long time) {

        Calendar cd = Calendar.getInstance();
        cd.setTime(new Date(time));

        int year  = cd.get(Calendar.YEAR); //获取年份
        int month = cd.get(Calendar.MONTH); //获取月份
        int day   = cd.get(Calendar.DAY_OF_MONTH); //获取日期
        int week  = cd.get(Calendar.DAY_OF_WEEK); //获取星期

        String weekString;
        switch (week) {
            case Calendar.SUNDAY:
                weekString = "日";
                break;
            case Calendar.MONDAY:
                weekString = "一";
                break;
            case Calendar.TUESDAY:
                weekString = "二";
                break;
            case Calendar.WEDNESDAY:
                weekString = "三";
                break;
            case Calendar.THURSDAY:
                weekString = "四";
                break;
            case Calendar.FRIDAY:
                weekString = "五";
                break;
            default:
                weekString = "六";
                break;
        }

        return weekString;
    }
}
